public class cwe {
    public class Died_Look {
        public static void main(String[] args) throws InterruptedException {
            Object o1 = new Object();
            Object o2 = new Object();
            Thread t1 = new Thread(()->{
                synchronized (o1){
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    synchronized (o2){
                        System.out.println("t1获取到两把锁");
                    }
                }
            });
            Thread t2 = new Thread(()->{
                synchronized (o2){
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    synchronized (o1){
                        System.out.println("t2获取到两把锁");
                    }
                }
            });
            t1.start();
            t2.start();
        }
    }

}
